function initSocket() {
  let socket = null;

  function connect(a, b) {
    socket = new WebSocket(`${process.env.VUE_APP_WS_URL}/websocket/message?${a}:${b}`);
    return socket;
  }

  function disconnect() {
    if (socket) {
      socket.close();
      socket = null;
      console.log("连接关闭")
    }
  }

  return { connect, disconnect };
}

export default initSocket;
/**
 * 初始化websocket连接
 * @param {*} a 设备还是项目
 * @param {*} b ID
 */